Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

391
Visualizações
"setColumnDefs" is not working on version 26.1.0 (Angular)

I have an angular project that uses Ag-Grid and here is my problem.

I thing that I have tried all that is in my hand but I'm not able to make it work... My code needs to add and remove some Columns dynamically, and in the documentation I saw that setColumnDefs from the GridApi was a good idea to try it.

I don't know If I'm doing something wrong, but I tried to follow the docs as much as I can.

This is the method that updates the columns definitions (it doesn't work)

updateColumnsMode(): void {
  if(!this.showAdvancedColumns) {
    this.gridOptions
        .api!
        .setColumnDefs(this.buildColumns(this.advancedColumnsName)));
  } else {
    this.gridOptions
        .api!
        .setColumnDefs(this.buildColumns(this.normalColumnsName)));
  }
}

My grid Options

gridOptions: GridOptions = {
  rowData: this.rowData,
  columnDefs: this.buildColumns(this.normalColumnsName),
  onGridReady: (event:any) => console.log("Grid working!"),
}

And the api initialization

onGridReady(params: any) {
  this.gridApi = params.api;
  this.gridColumnApi = params.columnApi;
}

And if it could be relevant, the method where I build the columns

buildColumns(columnsToBuild: String[]): ColDef[] {
  return columnsToBuild.map((column):any => {
    return { "field": column, sortable: true, filter: true }
  });
}

The columnsToBuild is jut an array of String.

I really need help with this guys.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda